package library.persistence.service;

import library.domain.User;
import library.persistence.impl.UserDaoImpl;

import java.util.List;

public class UserService {

    public List<User> getAllUser(){
        return new UserDaoImpl().getAllUser();
    };

    public User getUserByUserId(int userId){
        return new UserDaoImpl().getUserByID(userId);
    };

    public User getUserByUserName(String userName){
        return new UserDaoImpl().getUserByUsername(userName);
    };

    public void insertUser(User user){
        new UserDaoImpl().insertUser(user);
    };

    public void updateUserByUserId(User user){
        new UserDaoImpl().updateUserByID(user);
    };

    public void deleteUserByUserId(int id){
        new UserDaoImpl().deleteUserByID(id);
    };

    public void deleteUserByUserName(String username){
        new UserDaoImpl().deleteUserByUsername(username);
    };

    public List<User> searchUserList(String keyword){
        return new UserDaoImpl().searchUserList(keyword);
    }

//    public static void main(String[] args) {
//
//        UserService userService = new UserService();
//        List<User> userList = userService.getAllUser();
//        User user = userService.getUserByUserName("张三");
////        System.out.println(user.getId());
//        System.out.println(userList.get(0).getId());
//    }
}
